A vehicle for providing convenience of a driver or a passenger includes a plurality of electronic control devices. An eco-friendly vehicle such as a hybrid vehicle, an electric vehicle, and a hydrogen vehicle includes a larger number of electronic control devices than a vehicle operated by an engine using a fossil fuel.
An electronic control device or also known as “ECU” included in a vehicle may include an embedded system with a microprocessor installed therein. The embedded system refers to an application system including hardware and software for performing a specific function and the embedded system may be used in a field such as electric component control, robot control, and process control of a vehicle.
Since a control system for an eco-friendly vehicle is driven using driving force of a motor other than an engine, the system includes various controllers such as a motor controller for controlling a motor, an inverter, and the like, and a hybrid control unit (HCU) for controlling an overall operation of various electrical components of a vehicle, and thus, overall driving performance of a vehicle may be maintained when a real time operating system (RTOS) of each controller is managed without any problem.
When a program is executed in a control system of a vehicle, a memory required to execute a program may be allocated. The memory allocated for a program includes a code area (or a text area), a data area, a heap area, and a stack area. The stack area is a temporary memory area that is automatically used by a program and stores data that is temporarily used and then disappears, such as a local parameter, parameter, and a return value. While a vehicle travels, a control system needs to monitor, control, and manage electronic devices in a vehicle in response to a vehicle driving environment, a user/driver input, manipulation, and so on in real time. For example, a real-time operating system (RTOS) for managing a control system of a vehicle may be used in a STACK area in a memory.
In a procedure in which a plurality of programs or a plurality of functions are executed, in a stack area allocated for each program, each function, and each parameter, a program, a function, and a parameter use all areas allocated thereto and invades an area that is not allocated thereto to store information thereof. This case is referred to as stack overflow. Stack overflow may cause a problem such as program crash and stack overflow in a vehicle control system may adversely affect driving safety.